<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="wangyuguo">
	<title>选择限制油站</title>
	<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
	var tabs = {											//不同的tab触发的方法
		"station":{name:"tab_station",text:"限制机构",tabFunc:showStationList},
		"group":{name:"tab_group",text:"加油站组",tabFunc:showGroupList}
	};
	var stationLimitQt = null;
	var groupLimitQt = null;
	var stationList = true
	function load() {
		setPages(["datalist1","datalist2","detviewdiv"]);
		var ids = getPara("ids");
		if (ids){
			ids = ids.split(",")
			var str = ""
			for (var i=0;i<ids.length;i++){
				if (str) str += ",";
				str += "'" + ids[i] + "'";
			}
			searchForm.selectedCode.value = str;
		}
		Eui.buildTabs("tabsdiv",tabs);
		createStationLimitQt();
	}
	function createStationLimitQt() {
		if (!stationLimitQt){
			var columns = [
				{type:"checkbox"},
				{title:"编号",width:"30%"},
				{title:"名称",width:"70%"}
			]
			stationLimitQt = new QueryTable("sel_station_limit", "searchForm", "datalist1", columns,{
				exportable:false,
				columnsConf:false,
				paramFunc:paramFunc
			});
		}
		stationList = true;
		stationLimitQt.showTable();
	}
	function createGroupLimitQt() {
		if (!groupLimitQt){
			var columns = []
			columns[0] = {type:"checkbox"}
			columns[1] = {render : function(v,r){
				return "<a href=# onclick=\"onView("+r[0]+")\">"+v+"</a>";
			}}
			groupLimitQt = new QueryTable("sel_orggroup_limit", "searchForm", "datalist2", columns,{
				exportable:false,
				columnsConf:false,
				paramFunc:paramFunc
			});
		}
		stationList = false;
		groupLimitQt.showTable();
	}
	function paramFunc(){
		var params = Common.getValues("searchForm");
		params.name = params.name ? "%"+params.name+"%" : null;
		return params
	}
	function onView(id){
		DWR.call("partyService.getOrgGroup",id,function(data){
			var group = data.group;
			var members = data.members;
			var strs = "";
			for (var i=0;i<members.length;i++){
				var s = members[i];
				if (strs) strs += ",";
				strs += s[2];
			}
			$("orgGroupName").innerHTML = group.name;
			$("orgLevelText").innerHTML = Common.getText("org_level",group.orgLevel)
			$("memberNames").innerHTML = strs;
			switchPage("detviewdiv");
		},{blockScreen:true})
	}
	function doQuery(){
		if (stationList){
			stationLimitQt.showTable();
		}else
			groupLimitQt.showTable();
	}
	function showStationList(){
		switchPage("datalist1");
		createStationLimitQt();
	}
	function showGroupList(){
		switchPage("datalist2");
		createGroupLimitQt();
	}
	function onSave() {
		var res = []
		if (stationList){
			res = stationLimitQt.getBoxValue(true);
		}else
			res = groupLimitQt.getBoxValue(true);
		if (res.length<1){
			showWarning("请选择要限制加油的机构或者组");
			return;
		}
		dialogBackValue(res);
	}
</script>
<style>
	.tabsdiv{
		width:98%;
	}
	.tablist{
		margin-top:-10px;
	}
</style>
	</head>
<body class="body" onload="load()">
	<div id="listview">
		<!--查询条件form-->
		<div class="searchForm">
			<form id="searchForm" name="searchForm">
				<input type="hidden" name="parentOrg">
				<input type="hidden" name="orgLevel">
				<input type="hidden" name="selectedCode" id="selectedCode">
				<table cellSpacing="0" cellPadding="4" width="100%" border="0">
					<tr>
						<td>
							<label id="shopName">机构、机构组名称</label>
							<input type="text" name="name" maxlength="20">
						</td>
						<td><button type="button" onclick="doQuery()">查 询</button></td>
					</tr>
				</table>
			</form>
		</div>
		<div id='tabsdiv' align="left" class="tabsdiv">
		</div>
		<div id="datalist1" class="tablist"></div>
		<div id="datalist2" class="tablist" style="display:none;"></div>
		<div id="detviewdiv" class="tablist" style="display:none;">
			<div class="form">
				<div class="formTitle">机构组信息</div>
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable">
					<tr>
						<td><label>机构组名称</label> <span id="orgGroupName"></span></td>
						<td><label>机构等级</label> <span id="orgLevelText"></span></td>
					</tr>
					<tr>
						<td colspan="2"><label>成员机构</label> <span id="memberNames"></span></td>
					</tr>
				</table>
			</div>
			<p>
				<button onclick="switchPage('datalist2');">返 回</button>
			</p>
		</div>
	</div>
</body>
</html>
